package com.yinlixian.frame.entity;

import io.swagger.models.auth.In;

/**
 * @ClassName: ResultInfo
 * @Description: 存储结果信息，包括错误信息、结果等
 * @author: yudm
 * @date: 2017-03-03 18:41
 */
public class ResultInfo<T> {

    private Integer code;
    private String message;
    private String url;
    private T data;


    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public String getUrl() {
        return url;
    }

    public void setUrl(String url) {
        this.url = url;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }

    public void setResult(Result result){
        this.code = result.getCode();
        this.message = result.getMessage();
    }

    @Override
    public String toString() {
        return "ResultInfo{" +
                "code=" + code +
                ", message='" + message + '\'' +
                ", url='" + url + '\'' +
                ", data=" + data +
                '}';
    }

    public enum Result {
        OK(1,"操作成功")
        ,DefaultError(10,"系统错误")
        ,LoginError(11,"登录失败")
        ,AccessDenied(12,"访问未授权请重新登录")
        ;


        private Integer code;
        private String message;

        Result(Integer code,String message){
            this.code = code;
            this.message = message;
        }

        public Integer getCode() {
            return code;
        }

        public String getMessage() {
            return message;
        }
    }

}
